package factory.simplefactory;

/**
 * @author wcj
 * @Date 2021/6/20 21:52
 * @Version 1.0
 */
public class OperationFactory {

 public Operation getResult(String s) {
  Operation operation = null;
  switch (s) {
   case "+":
    operation = new OperationAdd();
    break;
   case "-":
    operation = new OperationSub();
    break;
   case "*":
    operation = new OperationMultiply();
    break;
   case "/":
    operation = new OperationDivide();
    break;
   default:
    throw new IllegalArgumentException("暂不支持此操作:" + s);
  }
  return operation;
 }
}
